package com.wzw.springboot.principle.mvc.argumentresolver;

import org.springframework.core.MethodParameter;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.method.support.ModelAndViewContainer;

/**
 * @author Wangzhiwen
 */
public class CustomizedHandlerMethodReturnValueHandler implements HandlerMethodReturnValueHandler {

    /**
     * 是否支持该返回值类型
      * @param returnType MethodParameter
     * @return true false
     */
    @Override
    public boolean supportsReturnType(MethodParameter returnType) {
        return true;
    }

    /**
     * 拦截返回值
     * @param returnValue 返回值
     * @param returnType 返回值类型
     * @param mavContainer 视图容器
     * @param webRequest request
     * @throws Exception 允许抛出异常
     */
    @Override
    public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
        // 进行拦截
    }
}
